package com.zynn.service.module.canal.service.impl;

import com.zynn.common.core.utils.TypeConvertUtil;
import com.zynn.feign.module.es.SyncEventFeignService;
import com.zynn.message.queue.constant.MqQueueNameConstant;
import com.zynn.service.module.canal.service.SchoolPopularityLikeService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.annotation.JmsListener;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 刘猛
 * @since 2018-09-14
 */
@Service
@Slf4j
public class SchoolPopularityLikeServiceImpl implements SchoolPopularityLikeService {

    @Autowired
    private SyncEventFeignService syncEventFeignService;

    @JmsListener(destination = MqQueueNameConstant.SCHOOL_POPULARITY_LIKE)
    public void findDegFriend(Map<String, Object> columnsMap) {
        log.info("FIND_FRIEND_FROM_SCHOOL_POPULARITY_LIKE:{}", columnsMap);
        /**
         * 被助力用户id
         */
        Long beLikeUserId = TypeConvertUtil.objectToLong(columnsMap.get("be_like_user_id"));
        if(beLikeUserId!=null && beLikeUserId!=0) {
            log.info("计算{}好友-高校版推荐", beLikeUserId);
            syncEventFeignService.initFriendVersionSchool(beLikeUserId,beLikeUserId);
        }
    }
}
